import { request } from 'umi';

/** 查询护工列表(300300000) */
export async function getWorkerList(
  params: {
    current?: number;
    pageSize?: number;
  } & HUMANRESOURCESAPI.WorkerItem
) {
  return request(`/api/manager/worker/${params.current}/limit/${params.pageSize}`, {
    method: 'POST',
    data: {
      ...params
    },
    headers: {
      Action_Id: '300300000'
    }
  });
}

// 查询护工信息-下载(300300010
export async function downWorkerList(
  params: {
    current?: number;
    pageSize?: number;
  } & HUMANRESOURCESAPI.WorkerItem
) {
  return request(`/api/manager/worker/report`, {
    method: 'POST',
    data: {
      ...params
    },
    headers: {
      Action_Id: '300300010'
    }
  });
}

/** 获取护工列表(无需权限ID) */
export async function getWorkerListByPage(
  params: { 
    flag?: number; 
    current?: number; 
    pageSize?: number;
  } & HUMANRESOURCESAPI.NursingItem
) {
  return request(`/api/manager/worker/page/${params.current}/limit/${params.pageSize}`, {
    method: 'POST',
    data: {
      ...params
    }
  });
}

/** 新建护工信息 */
export async function addWoker(data: HUMANRESOURCESAPI.WorkerItem) {
  return request('/api/manager/worker', {
    method: 'POST',
    data,
    headers: {
      Action_Id: '300300001'
    }
  });
}

/** 更新护工信息 */
export async function updateWoker(data: HUMANRESOURCESAPI.WorkerItem) {
  return request(`/api/manager/worker/${data.worker_id}`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: '300300002'
    }
  });
}

/** 查询护工服务记录(300300003,300300004)*/
export async function getServiceRecordList(
  params: {
    current?: number;
    pageSize?: number;
    worker_id?: string;
    begin_date?: string;
    end_date?: string;
    patient_name?: string;
  }
) {
  return request(`/api/manager/worker/${params.worker_id}/${params.current}/limit/${params.pageSize}`, {
    method: 'GET',
    params,
    headers: {
      Action_Id: '300300004'
    }
  });
}

// 导出护工服务记录(300300005)
export async function downServiceRecordList(
  params: {
    current?: number;
    pageSize?: number;
    worker_id?: string;
    begin_date?: string;
    end_date?: string;
    patient_name?: string;
  }
) {
  return request(`/api/manager/worker/${params.worker_id}/report`, {
    method: 'GET',
    params,
    headers: {
      Action_Id: '300300005'
    }
  });
}


/** 验证工号是否已存在 */
export async function checkWorkerNoIsExist(worker_no: string) {
  return request(`/api/manager/worker/${worker_no}/exist`, {
    method: 'GET'
  });
}

/**  保存缴费信息(300300009) */
export async function savePayInfo(data: HUMANRESOURCESAPI.PayItem & { worker_id: string;}) {
  return request(`/api/manager/worker/${data.worker_id}/pay`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '300300009'
    }
  });
}

/** 查询缴费记录(300300006)*/
export async function getPayRecord(params: {
  current?: number;
  pageSize?: number;
  worker_id?: string;
  begin_date?: string;
  end_date?: string;
  status?: string;
}) {
  return request(`/api/manager/worker/${params.worker_id}/pay/${params.current}/limit/${params.pageSize}`, {
    method: 'GET',
    params,
    headers: {
      Action_Id: '300300006'
    }
  });
}

// 缴费记录-导出查询结果(300300007
export async function downPayRecord(params: {
  current?: number;
  pageSize?: number;
  worker_id?: string;
  begin_date?: string;
  end_date?: string;
  status?: string;
}) {
  return request(`/api/manager/worker/${params.worker_id}/pay/report`, {
    method: 'GET',
    params,
    headers: {
      Action_Id: '300300007'
    }
  });
}

/** 查询护工服务单+缴费统计信息 */
export async function getWorkerSum(worker_id: string) {
  return request(`/api/manager/worker/${worker_id}/sum`, {
    method: 'GET'
  });
}

/** 作废记录(300300008) */
export async function dropRecord(pay_id: string) {
  return request(`/api/manager/worker/pay/${pay_id}`, {
    method: 'POST',
    headers: {
      Action_Id: '300300008'
    }
  });
}

// 批量修改护工状态(300300011)
export async function batchStatus(data) {
  return request(`/api/manager/worker/batch`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: '300300011'
    }
  });
}
// 查询护工详情
export async function getWorkerInfo(worker_id: string) {
  return request(`/api/manager/worker/${worker_id}`);
}

// 查询护工服务统计信息(300300013)
export async function getWorkerListSum(
  params: {
  } & HUMANRESOURCESAPI.WorkerItem
) {
  return request(`/api/manager/worker/sum`, {
    method: 'POST',
    data: {
      ...params
    },
    headers: {
      Action_Id: '300300013'
    }
  });
}
